package com.itcast.springboot.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {

    @Autowired
    Environment environment;

    //为API配置分组
    @Bean
    public Docket docketUser() {
        return new Docket(DocumentationType.SWAGGER_2)
                //为分组起名字
                .groupName("用户端")
                .select()
                //扫描对应的包
                .apis(RequestHandlerSelectors
                        .basePackage("com.itcast.springboot.waste_recovery.controller"))
                .paths(PathSelectors.ant("/**/customer/**"))
                .build();
    }

    //为API配置分组
    @Bean
    public Docket docketStaff() {
        return new Docket(DocumentationType.SWAGGER_2)
                //为分组起名字
                .groupName("员工端")
                .select()
                //扫描对应的包
                .apis(RequestHandlerSelectors
                        .basePackage("com.itcast.springboot.waste_recovery.controller"))
                .paths(PathSelectors.ant("/**/staff/**"))
                .build();
    }
}
